<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
  <meta name="generator" content="made with love by dartdoc 0.28.2">
  <meta name="description" content="dart_otp API docs, for the Dart programming language.">
  <title>dart_otp - Dart API docs</title>

  <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500,400i,400,300|Source+Sans+Pro:400,300,700" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="static-assets/github.css">
  <link rel="stylesheet" href="static-assets/styles.css">
  <link rel="icon" href="static-assets/favicon.png">
  
</head>

<body>

<div id="overlay-under-drawer"></div>

<header id="title">
  <button id="sidenav-left-toggle" type="button">&nbsp;</button>
  <ol class="breadcrumbs gt-separated dark hidden-xs">
    <li><a href="https://github.com/BrunoMiguens/dart_otp">dart_otp package</a></li>
  </ol>
  <div class="self-name">dart_otp</div>
  <form class="search navbar-right" role="search">
    <input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
  </form>
</header>

<main>

  <div id="dartdoc-sidebar-left" class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left">
    <header id="header-search-sidebar" class="hidden-l">
      <form class="search-sidebar" role="search">
        <input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
      </form>
    </header>
    
    <ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
      <li><a href="https://github.com/BrunoMiguens/dart_otp">dart_otp package</a></li>
    </ol>
    
    <h5 class="hidden-xs"><span class="package-name">dart_otp</span> <span class="package-kind">package</span></h5>
    <ol>
          <li class="section-title">Libraries</li>
          <li><a href="dart_otp/dart_otp-library.html">dart_otp</a></li>
    </ol>
  </div>

  <div id="dartdoc-main-content" class="col-xs-12 col-sm-9 col-md-8 main-content">
      <section class="desc markdown">
        <h1 id="dart_otp">dart_otp</h1>
<p><a href="https://pub.dev/packages/dart_otp"><img src="https://img.shields.io/pub/v/dart_otp.svg" alt="pub package"></a>
<a href="https://travis-ci.org/BrunoMiguens/dart_otp"><img src="https://travis-ci.org/BrunoMiguens/dart_otp.svg?branch=master" alt="Build Status"></a>
<a href="https://coveralls.io/github/BrunoMiguens/dart_otp?branch=master"><img src="https://coveralls.io/repos/github/BrunoMiguens/dart_otp/badge.svg?branch=master" alt="Coverage Status"></a></p>
<p><code>dart_otp</code> is a dart package to generate and verify one-time passwords that were used to implement 2FA and MFA authentication method in web applications and other login-required systems.</p>
<p>The package was implement based on <a href="https://tools.ietf.org/html/rfc4226">RFC4226</a> (HOTP: An HMAC-Based One-Time Password Algorithm) and <a href="https://tools.ietf.org/html/rfc6238">RFC6238</a> (TOTP: Time-Based One-Time Password Algorithm).</p>
<h2 id="feature">Feature</h2><ul><li>Generate a <code>otpauth url</code> with the b32 encoded string</li><li>Create and verify a HOTP object</li><li>Create and verify a TOTP object</li></ul>
<h3 id="installation">Installation</h3>
<h4 id="pubspec">Pubspec</h4>
<p>Add <code>dart_otp</code> as a dependency in your <code>pubspec.yaml</code> file.</p>
<pre class="language-yaml"><code class="language-yaml">dependencies:
  dart_otp: ^1.3.0
</code></pre>
<h3 id="example">Example</h3>
<h4 id="time-based-otps">Time-based OTPs</h4>
<pre class="language-dart"><code class="language-dart">import 'package:dart_otp/dart_otp.dart';

void main() {

  /// default initialization for intervals of 30 seconds and 6 digit tokens
  TOTP totp = TOTP(secret: "J22U6B3WIWRRBTAV");

  /// initialization for custom interval and digit values
  TOTP totp = TOTP(secret: "J22U6B3WIWRRBTAV", interval: 60, digits: 8);

  totp.now(); /// =&gt; 432143

  /// verify for the current time
  totp.verify(otp: 432143); /// =&gt; true

  /// verify after 30s
  totp.verify(otp: 432143); /// =&gt; false
}
</code></pre>
<h4 id="counter-based-otps">Counter-based OTPs</h4>
<pre class="language-dart"><code class="language-dart">import 'package:dart_otp/dart_otp.dart';

void main() {

  /// default initialization 6 digit tokens
  HOTP hotp = HOTP(secret: "J22U6B3WIWRRBTAV");

  /// initialization for custom digit value
  HOTP hotp = HOTP(secret: "J22U6B3WIWRRBTAV", counter: 50, digits: 8);

  hotp.at(counter: 0); /// =&gt; 432143
  hotp.at(counter: 1); /// =&gt; 231434
  hotp.at(counter: 2132); /// =&gt; 242432

  /// verify with a counter
  hotp.verify(otp: 242432, counter: 2132); /// =&gt; true
  hotp.verify(otp: 242432, counter: 2133); /// =&gt; false
}
</code></pre>
<h3 id="release-notes">Release notes</h3>
<p>See <a href="./CHANGELOG.md">CHANGELOG.md</a>.</p>
      </section>
      
        <section class="summary">
            <h2>Libraries</h2>
          <dl>
            <dt id="dart_otp">
              <span class="name"><a href="dart_otp/dart_otp-library.html">dart_otp</a></span>             
            </dt>
            <dd>
              @project  : dart_otp
@author   : Gin (gin.lance.inside@hotmail.com)
@link     : <a href="https://github.com/BrunoMiguens/dart_otp">https://github.com/BrunoMiguens/dart_otp</a>
@Disc     : a dart package to generate and verify one-time passwords
            </dd>          </dl>
        </section>

  </div> <!-- /.main-content -->

  <div id="dartdoc-sidebar-right" class="col-xs-6 col-sm-6 col-md-2 sidebar sidebar-offcanvas-right">
  </div>

</main>

<footer>
  <span class="no-break">
    dart_otp 1.3.0
  </span>

  
</footer>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="static-assets/typeahead.bundle.min.js"></script>
<script src="static-assets/highlight.pack.js"></script>
<script src="static-assets/URI.js"></script>
<script src="static-assets/script.js"></script>


</body>

</html>
